Ch.10 Matrix Operations

Return to TOC

Operations on Linear Functions

Scalar Multiplication and Addition

Recall that if f:VWf:V\to W is a linear function and rRr\in\mathbb{R} then the scalar multiple function
vrfrf(v)\vec{v}\xmapsto{rf}r\cdot f(\vec{v})
is also linear, and for linear functions f,g:VWf,g:V\to W the sum
vf+gf(v)+g(v)\vec{v}\xmapsto{f+g}f(\vec{v})+g(\vec{v})
is also linear.

Similarly, if H,GH,G are matrices representing linear functions f,g:VWf,g:V\to W with respect to bases BB and DD, then rfrf is represented by rHrH and f+gf+g is represented by H+GH+G
Here, rr is the scalar multiple of a matrix and H+GH+G is the sum, defined only for same-size matrices

Example 10.1

Fix domain VV and codomain WW with bases B=β1,...,βnB=\langle\vec{\beta}_1,...,\vec{\beta}_n\rangle and D=δ1,...,δnD=\langle\vec{\delta}_1,...,\vec{\delta}_n\rangle.
Let h:VWh:V\to W be a linear map and consider the map rh:VWr\cdot h:V\to W given by vrhrh(v)\vec{v}\xmapsto{r\cdot h}r\cdot h(\vec{v}).
If the representation of h(v)h(\vec{v}) is
RepD(h(v))=(w1wn)\text{Rep}_D(h(\vec{v}))=\begin{pmatrix}w_1\\\vdots\\w_n\end{pmatrix}
Then rh(v)=r(w1δ1++wnδn)=(rw1)δ1++(rwn)δnr\cdot h(\vec{v})=r\cdot(w_1\vec{\delta}_1+\cdots+w_n\vec{\delta}_n)=(r\cdot w_1)\vec{\delta}_1+\cdots+(r\cdot w_n)\vec{\delta}_n, so
RepD(rh(v))=(rw1rwn)=r(w1wn)\text{Rep}_D(r\cdot h(\vec{v}))=\begin{pmatrix}r\cdot w_1\\\vdots\\r\cdot w_n\end{pmatrix}=r\cdot\begin{pmatrix}w_1\\\vdots\\w_n\end{pmatrix}
The output is rr times bigger.
So if HH is the matrix representing hh, rHrH represents rhrh.
Similarly, if ff is represented by HH and gg is represented by GG, then f+gf+g is represented by H+GH+G.

For two matrices with different sizes, their domains or codomains are different, so the function sum would not be possible. Therefore, the matrix sum is not defined.

The zero matrix has all entries 00, denoted as Zn×m,Z,0n×n,Z_{n\times m},Z,0_{n\times n}, or simply 00.
This is the additive identity for matrix addition.
The zero function Z:VWZ:V\to W is the identity for function addition.

Composition

composition of linear functions is linear

Proof

Let h:VWh:V\to W and g:WUg:W\to U be linear.
Then gh(c1v1+c2v2)=g(h(c1v1+c2v2))=g(c1h(v1)+c2h(v2))=c1g(h(v1))+c2g(h(v2))=c1gh(v1)+c2gh(v2)\begin{array}{rcl}g\circ h(c_1\cdot\vec{v}_1+c_2\cdot\vec{v}_2)&=&g(h(c_1\cdot\vec{v}_1+c_2\cdot\vec{v}_2))\\&=&g(c_1\cdot h(\vec{v}_1)+c_2\cdot h(\vec{v}_2))\\&=&c_1\cdot g(h(\vec{v}_1))+c_2\cdot g(h(\vec{v}_2))\\&=&c_1\cdot g\circ h(\vec{v}_1)+c_2\cdot g\circ h(\vec{v}_2)\end{array}
shows ghg\circ h is linear

A composition of linear maps is represented by the matrix-multiplicative product of an m×rm\times r matrix GG and an r×nr\times n matrix HH, which yields an m×nm\times n matrix PP where
Pi,j=gi,1h1,j+gi,2h2,j++gi,rhr,jP_{i,j}=g_{i,1}h_{1,j}+g_{i,2}h_{2,j}+\cdots+g_{i,r}h_{r,j}
So the i,ji,j-th entry of PP is the dot product of the ii-th row of GG and the jj-th column of HH
GH=(gi,1gi,2gi,r)(h1,jh2,jhr,j)=(pi,j)GH=\begin{pmatrix}&\vdots&&\\g_{i,1}&g_{i,2}&\cdots&g_{i,r}\\&\vdots&&\end{pmatrix}\begin{pmatrix}&h_{1,j}&\\\cdots&h_{2,j}&\cdots\\&\vdots&\\&h_{r,j}&\end{pmatrix}=\begin{pmatrix}&\vdots&\\\cdots&p_{i,j}&\cdots\\&\vdots&\end{pmatrix}

Example 10.2

Compute
(231142)(011251123)\begin{pmatrix}2&3&1\\1&4&2\end{pmatrix}\begin{pmatrix}0&1&1\\2&5&1\\1&2&3\end{pmatrix}


This will result in a 2×32\times3 matrix
(abcdef)\begin{pmatrix}a&b&c\\d&e&f\end{pmatrix}
a=2(0)+3(2)+1(1)=7b=2(1)+3(5)+1(2)=19c=2(1)+3(1)+1(3)=8d=1(0)+4(2)+2(1)=10e=1(1)+4(5)+2(2)=25f=1(1)+4(1)+2(3)=11a=2(0)+3(2)+1(1)=7\\ b=2(1)+3(5)+1(2)=19\\ c=2(1)+3(1)+1(3)=8\\ d=1(0)+4(2)+2(1)=10\\ e=1(1)+4(5)+2(2)=25\\ f=1(1)+4(1)+2(3)=11

Proof

Let h:VWh:V\to W and g:WXg:W\to X be represented by matrices HH and GG with respect to bases BVB\subset V, CWC\subset W, DXD\subset X of sizes n,r,mn,r,m.

For any vV\vec{v}\in V, the kk-th component (1kr1\le k\le r) of RepC(h(v))\text{Rep}_C(h(\vec{v})) is hk,1v1++hk,nvnh_{k,1}v_1+\cdots+h_{k,n}v_n,
so the ii-th component of RepD(gh(v))\text{Rep}_D(g\circ h(\vec{v})) is
gi,1(h1,1v1++h1,nvn)++gi,r(hr,1v1++hr,nvn)g_{i,1}(h_{1,1}v_1+\cdots+h_{1,n}v_n)+\cdots+g_{i,r}(h_{r,1}v_1+\cdots+h_{r,n}v_n)
Distributing and grouping by the vv's
(gi,1h1,1+gi,2h2,1++gi,rhr,n)v1++(gi,1h1,n+gi,2h2,n++gi,rhr,n)vn(g_{i,1}h_{1,1}+g_{i,2}h_{2,1}+\cdots+g_{i,r}h_{r,n})v_1+\cdots+(g_{i,1}h_{1,n}+g_{i,2}h_{2,n}+\cdots+g_{i,r}h_{r,n})v_n
Each coefficient of vv's matches the definition for the i,ji,j-th entry of the product GHGH

This image shows the relationship between maps and matrices

It simply shows there are two ways to get from vV\vec{v}\in V to g(h(v))g(h(\vec{v}))

Example 10.3

Let V=R2V=\mathbb{R}^2, W=P2W=\mathcal{P}_2, X=M2×2X=\mathcal{M}_{2\times2} with bases
B=(11),(11)C=x2,x2+x,x2+x+1\begin{array}{cc}B=\langle\begin{pmatrix}1\\1\end{pmatrix},\begin{pmatrix}1\\-1\end{pmatrix}\rangle&C=\langle x^2,x^2+x,x^2+x+1\rangle\end{array}
D=(1000),(0200),(0030),(0004)D=\langle\begin{pmatrix}1&0\\0&0\end{pmatrix},\begin{pmatrix}0&2\\0&0\end{pmatrix},\begin{pmatrix}0&0\\3&0\end{pmatrix},\begin{pmatrix}0&0\\0&4\end{pmatrix}\rangle
Suppose h:R2P2h:\mathbb{R}^2\to\mathcal{P}_2 and g:P2M2×2g:\mathcal{P}_2\to\mathcal{M}_{2\times2} have these actions
(ab)hax2+(a+b)px2+qx+rg(pp+q0r)\begin{array}{cc}\begin{pmatrix}a\\b\end{pmatrix}\xmapsto{h}ax^2+(a+b)&px^2+qx+r\xmapsto{g}\begin{pmatrix}p&p+q\\0&r\end{pmatrix}\end{array}
and the matrices GG and HH represent gg and hh.
We will check that the matrix product GHGH represents ghg\circ h

The composition has the action
(ab)gh(aa0a+b)\begin{pmatrix}a\\b\end{pmatrix}\xmapsto{g\circ h}\begin{pmatrix}a&a\\0&a+b\end{pmatrix}

Now, we find the matrix HH
(11)=RepB((10))hx2+2=RepC((122))\begin{pmatrix}1\\1\end{pmatrix}=\text{Rep}_B(\begin{pmatrix}1\\0\end{pmatrix})\xmapsto{h}x^2+2=\text{Rep}_C(\begin{pmatrix}1\\-2\\2\end{pmatrix})
(11)=RepB((01))hx2=RepC((100))\begin{pmatrix}1\\-1\end{pmatrix}=\text{Rep}_B(\begin{pmatrix}0\\1\end{pmatrix})\xmapsto{h}x^2=\text{Rep}_C(\begin{pmatrix}1\\0\\0\end{pmatrix})
So
H=(112020)H=\begin{pmatrix}1&1\\-2&0\\2&0\end{pmatrix}

Next, to find GG
x2=RepC((100))g(1100)=RepD((11/200))x^2=\text{Rep}_C(\begin{pmatrix}1\\0\\0\end{pmatrix})\xmapsto{g}\begin{pmatrix}1&1\\0&0\end{pmatrix}=\text{Rep}_D(\begin{pmatrix}1\\1/2\\0\\0\end{pmatrix})
x2+x=RepC((110))g(1200)=RepD((1100))x^2+x=\text{Rep}_C(\begin{pmatrix}1\\1\\0\end{pmatrix})\xmapsto{g}\begin{pmatrix}1&2\\0&0\end{pmatrix}=\text{Rep}_D(\begin{pmatrix}1\\1\\0\\0\end{pmatrix})
x2+x+1=RepC((111))g(1201)=RepD((1101/4))x^2+x+1=\text{Rep}_C(\begin{pmatrix}1\\1\\1\end{pmatrix})\xmapsto{g}\begin{pmatrix}1&2\\0&1\end{pmatrix}=\text{Rep}_D(\begin{pmatrix}1\\1\\0\\1/4\end{pmatrix})
So
G=(1111/211000001/4)G=\begin{pmatrix}1&1&1\\1/2&1&1\\0&0&0\\0&0&1/4\end{pmatrix}
Now, we compute GHGH
GH=(1111/211000001/4)(112020)=(1(1)+1(2)+1(2)11/2(1)+1(2)+1(2)1/2001/4(2)0)=(111/21/2001/20)GH=\begin{pmatrix}1&1&1\\1/2&1&1\\0&0&0\\0&0&1/4\end{pmatrix}\begin{pmatrix}1&1\\-2&0\\2&0\end{pmatrix}=\begin{pmatrix}1(1)+1(-2)+1(2)&1\\1/2(1)+1(-2)+1(2)&1/2\\0&0\\1/4(2)&0\end{pmatrix}=\begin{pmatrix}1&1\\1/2&1/2\\0&0\\1/2&0\end{pmatrix}

We check this by finding the matrix representation of ghg\circ h
(11)=RepB((10))gh(1102)=RepD((11/201/2))\begin{pmatrix}1\\1\end{pmatrix}=\text{Rep}_B(\begin{pmatrix}1\\0\end{pmatrix})\xmapsto{g\circ h}\begin{pmatrix}1&1\\0&2\end{pmatrix}=\text{Rep}_D(\begin{pmatrix}1\\1/2\\0\\1/2\end{pmatrix})
(11)=RepB((01))gh(1100)=RepD((11/200))\begin{pmatrix}1\\-1\end{pmatrix}=\text{Rep}_B(\begin{pmatrix}0\\1\end{pmatrix})\xmapsto{g\circ h}\begin{pmatrix}1&1\\0&0\end{pmatrix}=\text{Rep}_D(\begin{pmatrix}1\\1/2\\0\\0\end{pmatrix})
This yields the matrix
GH=(111/21/2001/20)GH=\begin{pmatrix}1&1\\1/2&1/2\\0&0\\1/2&0\end{pmatrix}
which is equal to what was computed before.

Note that the order of matrices is the same as function composition
i.e., ghg\circ h applies hh, then gg, and the matrix product GHGH multiplies the input by HH, then GG.

Matrix multiplication is not commutative.

Example 10.4

Are thse two matrix products equal?
(1234)(2401)(2401)(1234)\begin{array}{cc}\begin{pmatrix}1&2\\3&4\end{pmatrix}\begin{pmatrix}2&4\\0&1\end{pmatrix}&\begin{pmatrix}2&4\\0&1\end{pmatrix}\begin{pmatrix}1&2\\3&4\end{pmatrix}\end{array}


The first yields
(1234)(2401)=(1(2)+2(0)1(4)+2(1)3(2)+4(0)3(4)+4(1))=(26616)\begin{pmatrix}1&2\\3&4\end{pmatrix}\begin{pmatrix}2&4\\0&1\end{pmatrix}=\begin{pmatrix}1(2)+2(0)&1(4)+2(1)\\3(2)+4(0)&3(4)+4(1)\end{pmatrix}=\begin{pmatrix}2&6\\6&16\end{pmatrix}

The second yields
(2401)(1234)=(2(1)+4(3)2(2)+4(4)0(1)+1(3)0(2)+1(4))=(142034)\begin{pmatrix}2&4\\0&1\end{pmatrix}\begin{pmatrix}1&2\\3&4\end{pmatrix}=\begin{pmatrix}2(1)+4(3)&2(2)+4(4)\\0(1)+1(3)&0(2)+1(4)\end{pmatrix}=\begin{pmatrix}14&20\\3&4\end{pmatrix}

Clearly, they are not equal.
(26616)(142034)\begin{pmatrix}2&6\\6&16\end{pmatrix}\ne\begin{pmatrix}14&20\\3&4\end{pmatrix}

However, there are some nice properties
Given matrices F,G,HF,G,H where the matrix products are defined:

Proof

Matrix multiplication represents function composition, so (FG)H(FG)H is (fg)h(f\circ g)\circ h and F(GH)F(GH) is f(gh)f\circ(g\circ h), both of which are equivalent to fghf\circ g\circ h

Proof

Proofs for both sides are similar, so we only prove F(G+H)=FG+FHF(G+H)=FG+FH
Converting to function composition, we must prove that f(g+h)(v)=fg(v)+fh(v)f\circ(g+h)(\vec{v})=f\circ g(\vec{v})+f\circ h(\vec{v})
f(g+h)(v)=f(g(v)+h(v))=f(g(v))+f(h(v))=fg(v)+fh(v)f\circ(g+h)(\vec{v})=f(g(\vec{v})+h(\vec{v}))=f(g(\vec{v}))+f(h(\vec{v}))=f\circ g(\vec{v})+f\circ h(\vec{v})


Mechanics

Columns of GHGH are formed by taking GG times columns of HH
Rows of GHGH are formed by taking rows of GG times HH
Proof is just computation

Example 10.5

We can apply the operation (1/2)ρ2(1/2)\rho_2 on the matrix
(123025000)\begin{pmatrix}1&2&3\\0&2&5\\0&0&0\end{pmatrix}
or we can apply the operator to the identity matrix and multiply with the matrix
(10001/20001)(123025000)\begin{pmatrix}1&0&0\\0&1/2&0\\0&0&1\end{pmatrix}\begin{pmatrix}1&2&3\\0&2&5\\0&0&0\end{pmatrix}
The same can be done with the other operations

Example 10.6

Gaussian reduction can be performed with row operators
(1234)3ρ1+ρ2(1202)ρ2+ρ1(1002)1/2ρ2(1001)\begin{pmatrix}1&2\\3&4\end{pmatrix}\xrightarrow{-3\rho_1+\rho_2}\begin{pmatrix}1&2\\0&-2\end{pmatrix}\xrightarrow{\rho_2+\rho_1}\begin{pmatrix}1&0\\0&-2\end{pmatrix}\xrightarrow{-1/2\rho_2}\begin{pmatrix}1&0\\0&1\end{pmatrix}
Or the elementary matrices can be multiplied instead
(1001/2)(1101)(1031)(1234)=(1001)\begin{pmatrix}1&0\\0&-1/2\end{pmatrix}\begin{pmatrix}1&1\\0&1\end{pmatrix}\begin{pmatrix}1&0\\-3&1\end{pmatrix}\begin{pmatrix}1&2\\3&4\end{pmatrix}=\begin{pmatrix}1&0\\0&1\end{pmatrix}
Each of the matrices (from the right) are the elementary matrices for each row operator step


Inverses

Recall: right inverse, left inverse, two-sided inverse (is unique)

If a matrix has both a left and right matrix, they are equal.
A matrix is invertible iff it is nonsingular.
Proof is simple: Fix dimensions and bases, then a matrix represents a map, and these are true of maps so they are true of matrices.

If GG and HH are invertible matrices, GHGH (if defined) is invertible with (GH)1=H1G1(GH)^{-1}=H^{-1}G^{-1}

A matrix HH is invertible iff it can be written as the product of elementary reduction matrices.

Proof

HH is invertible iff it is nonsingular, so it Gaus-Jordan reduces to the identity through a series of operations
RrRr1R1H=IR_r\cdot R_{r-1}\cdots R_1 \cdot H=I
Each row operation is invertible, and the inverses are elementary.
Apply Rr1R_r^{-1}, then Rr11R_{r-1}^{-1} etc to both sides to get
H=Rr1Rr11R11IH=R_r^{-1}\cdot R_{r-1}^{-1}\cdots R_1^{-1}\cdot I
This represents HH as the product of elementary operations.

The inverse can be computed by multiplying the same reduction matrices in the same order to the identity matrix.
Proof

Group as
(RrRr1R1)H=I(R_r\cdot R_{r-1}\cdots R_1) \cdot H=I
Then we have
H1=RrRr1R1IH^{-1}=R_r\cdot R_{r-1}\cdots R_1\cdot I

Thus, to find the inverse, we write the identity matrix next to the matrix we want to find the inverse of, and row reduce the matrix.

Example 10.7

Find the inverse of
A=(131201120)A=\begin{pmatrix}1&3&1\\2&0&-1\\1&2&0\end{pmatrix}


(131100201010120001)ρ1+ρ22ρ1+ρ2(131100063210011101)3ρ3+ρ16ρ3+ρ2(102203003416011101)ρ31/3ρ2(1022030111010014/31/32)2ρ3+ρ1ρ3+ρ2(1002/32/310101/31/310014/31/32)\begin{array}{cccccc}&\left(\begin{array}{ccc|ccc}1&3&1&1&0&0\\2&0&-1&0&1&0\\1&2&0&0&0&1\end{array}\right)&\xrightarrow[-\rho_1+\rho_2]{-2\rho_1+\rho_2}&\left(\begin{array}{ccc|ccc}1&3&1&1&0&0\\0&-6&-3&-2&1&0\\0&-1&-1&-1&0&1\end{array}\right)&\xrightarrow[3\rho_3+\rho_1]{-6\rho_3+\rho_2}&\left(\begin{array}{ccc|ccc}1&0&-2&-2&0&3\\0&0&3&4&1&-6\\0&-1&-1&-1&0&1\end{array}\right)\\\xrightarrow{-\rho_3\leftrightarrow1/3\rho_2}&\left(\begin{array}{ccc|ccc}1&0&-2&-2&0&3\\0&1&1&1&0&-1\\0&0&1&4/3&1/3&-2\end{array}\right)&\xrightarrow[2\rho_3+\rho_1]{-\rho_3+\rho_2}&\left(\begin{array}{ccc|ccc}1&0&0&2/3&2/3&-1\\0&1&0&-1/3&-1/3&1\\0&0&1&4/3&1/3&-2\end{array}\right)\end{array}
Thus the inverse is
A1=(2/32/311/31/314/31/32)A^{-1}=\begin{pmatrix}2/3&2/3&-1\\-1/3&-1/3&1\\4/3&1/3&-2\end{pmatrix}

The inverse of a 2×22\times2 matrix exists iff adbc0ad-bc\ne0 and is
(abcd)1=1adbc(dbca)\begin{pmatrix}a&b\\c&d\end{pmatrix}^{-1}=\frac{1}{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}
The proof is a matter of trying it yourself.


The inverse of representation matrix is
(RepB,D(h))1=RepD,B(h1)(\text{Rep}_{B,D}(h))^{-1}=\text{Rep}_{D,B}(h^{-1})